package com.indexingsystem.db.mongoDB.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

import org.apache.commons.lang3.StringUtils;
import org.bson.Document;
import org.bson.conversions.Bson;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.indexingsystem.boss.Vo.MagazinesTableVo;
import com.indexingsystem.boss.Vo.WebChatSharesVo;
import com.indexingsystem.boss.entity.AuditLogs;
import com.indexingsystem.boss.entity.DhResourceauditlogs;
import com.indexingsystem.boss.entity.DhTodayStorageInfos;
import com.indexingsystem.boss.entity.Magazines;
import com.indexingsystem.boss.entity.ResCategoryRelations;
import com.indexingsystem.boss.entity.ResourceRelations;
import com.indexingsystem.boss.entity.Resources;
import com.indexingsystem.boss.entity.SpecialResourceDatas;
import com.indexingsystem.boss.entity.WechatShares;
import com.indexingsystem.boss.logback.LogCvt;
import com.indexingsystem.boss.utils.JsonUtils;
import com.indexingsystem.db.mongoDB.MongoManager;
import com.indexingsystem.db.mongoDB.comon.MongoDBUtils;
import com.indexingsystem.db.mongoDB.comon.MongoTableName;
import com.indexingsystem.db.mongoDB.po.MagazinesResourceMongoVo;
import com.indexingsystem.db.mongoDB.po.WeChatSharesMongoVo;
import com.mongodb.BasicDBObject;
import com.mongodb.client.model.Filters;

/**
 * 储存图文结构Mongo内存操作实现类
 * 
 * @author Administrator
 * 
 */
public class WeChatSharesMongo {

	/**
	 * 新增
	 * 
	 * @param weChatSharesMongoVo
	 * @throws Exception
	 */
	public static void addWechatShares(WeChatSharesMongoVo weChatSharesMongoVo, String institutionId) throws Exception {
		MongoManager manager = new MongoManager();
		LogCvt.debug( MongoTableName.DH_WECHAT_SHARES_RESOURCE + "添加 ------->" + com.alibaba.fastjson.JSON.toJSONString( weChatSharesMongoVo, true ) );
		if (null != weChatSharesMongoVo) {
			Document mainDocument = new Document();
			mainDocument.put( "_id", weChatSharesMongoVo.getResId() );
			mainDocument.put( "resId", weChatSharesMongoVo.getResId() );
			mainDocument.put( "resTypeId", weChatSharesMongoVo.getResTypeId() );
			mainDocument.put( "resTable", weChatSharesMongoVo.getResTable() );
			mainDocument.put( "institutionId", institutionId );

			Document wechatSharesDoc = MongoDBUtils.transform2Doc( weChatSharesMongoVo.getWechatShares() );
			mainDocument.put( "wechatShares", wechatSharesDoc );

			Document resourcesDoc = MongoDBUtils.transform2Doc( weChatSharesMongoVo.getResources() );
			mainDocument.put( "resources", resourcesDoc );

			Document resourceauditlogsDoc = MongoDBUtils.transform2Doc( weChatSharesMongoVo.getResourceauditlogs() );
			mainDocument.put( "resourceauditlogs", resourceauditlogsDoc );

			Document auditLogsDoc = MongoDBUtils.transform2Doc( weChatSharesMongoVo.getAuditLogs() );
			mainDocument.put( "auditLogs", auditLogsDoc );

			Document todayStorageInfosDoc = MongoDBUtils.transform2Doc( weChatSharesMongoVo.getTodayStorageInfos() );
			mainDocument.put( "todayStorageInfos", todayStorageInfosDoc );

			List<Document> specialResourceDatasDocList = new ArrayList<Document>();
			if (null != weChatSharesMongoVo.getDhSpecialResourceDatasList() && weChatSharesMongoVo.getDhSpecialResourceDatasList().size() > 0) {
				for (SpecialResourceDatas specialResourceDatas : weChatSharesMongoVo.getDhSpecialResourceDatasList()) {
					Document specialResourceDatasDoc = MongoDBUtils.transform2Doc( specialResourceDatas );
					specialResourceDatasDocList.add( specialResourceDatasDoc );
				}
			}
			mainDocument.put( "dhSpecialResourceDatasList", specialResourceDatasDocList );

			// 资源关系列表
			List<Document> dhResourceRelationsDocList = new ArrayList<Document>();
			if (null != weChatSharesMongoVo.getDhResourceRelationsList() && weChatSharesMongoVo.getDhResourceRelationsList().size() > 0) {
				for (ResourceRelations resourceRelations : weChatSharesMongoVo.getDhResourceRelationsList()) {
					Document resourceRelationsDoc = MongoDBUtils.transform2Doc( resourceRelations );
					dhResourceRelationsDocList.add( resourceRelationsDoc );
				}
			}
			mainDocument.put( "dhResourceRelationsList", dhResourceRelationsDocList );

			// 资源分类关系列表
			List<Document> resCategoryRelationsList = new ArrayList<Document>();
			if (null != weChatSharesMongoVo.getResCategoryRelationsList() && weChatSharesMongoVo.getResCategoryRelationsList().size() > 0) {
				for (ResCategoryRelations dhResourceCategoryRelations : weChatSharesMongoVo.getResCategoryRelationsList()) {
					Document resCategoryRelationsVoDoc = MongoDBUtils.transform2Doc( dhResourceCategoryRelations );
					resCategoryRelationsList.add( resCategoryRelationsVoDoc );
				}
			}
			mainDocument.put( "resCategoryRelationsList", resCategoryRelationsList );

			manager.add( mainDocument, MongoTableName.DH_WECHAT_SHARES_RESOURCE );
		}
	}

	/**
	 * 批量删除图文更新mongodb
	 * 
	 * @param map
	 * @return
	 */
	public static void deleteWeChatSharesByIds(List<String> resIdList, String institutionId) {
		MongoManager manager = new MongoManager();
		Bson bson = Filters.and( Filters.in( "resId", resIdList ), Filters.eq( "institutionId", institutionId ) );
		manager.deleteAll( bson, MongoTableName.DH_WECHAT_SHARES_RESOURCE );
	}

	/**
	 * 查询图文列表
	 * 
	 * @param webChatSharesVo
	 * @return
	 */
	public static List<WebChatSharesVo> findWebChatShareslesByPage(WebChatSharesVo webChatSharesVo, String institutionId) {
		MongoManager manager = new MongoManager();
		LogCvt.debug( MongoTableName.DH_WECHAT_SHARES_RESOURCE + "查图文列表 ------->" );
		List<WebChatSharesVo> webChatSharesVosList = null;
		BasicDBObject basicDBObject = new BasicDBObject();
		basicDBObject.put( "institutionId", institutionId );

		if (StringUtils.isNotBlank( webChatSharesVo.getQueryCriteria() )) {
			Pattern pattern = Pattern.compile( ".*" + webChatSharesVo.getQueryCriteria() + ".*", Pattern.CASE_INSENSITIVE );
			basicDBObject.put( "wechatShares.title", pattern );
		}
		if (null != webChatSharesVo.getStatus()) {
			basicDBObject.put( "resources.status", webChatSharesVo.getStatus() );
		}
		// 时间查询
		if (webChatSharesVo.getStartPublishDate() != null && !webChatSharesVo.getStartPublishDate().equals( "" )) {
			BasicDBObject gt = new BasicDBObject( "$gte", webChatSharesVo.getStartPublishDate() );
			basicDBObject.put( "wechatShares.operattime", gt );
		}
		if (webChatSharesVo.getEndPublishDate() != null && !webChatSharesVo.getEndPublishDate().equals( "" )) {
			BasicDBObject lt = new BasicDBObject( "$lte", webChatSharesVo.getEndPublishDate() );
			basicDBObject.put( "wechatShares.operattime", lt );
		}
		if (StringUtils.isNotBlank( webChatSharesVo.getAuthor() )) {
			Pattern pattern = Pattern.compile( ".*" + webChatSharesVo.getAuthor() + ".*", Pattern.CASE_INSENSITIVE );
			basicDBObject.put( "wechatShares.author", pattern );
		}
		if (StringUtils.isNotBlank( webChatSharesVo.getTerminalCode() )) {
			basicDBObject.put( "dhSpecialResourceDatasList.terminalCode", webChatSharesVo.getTerminalCode() );
		}
		if (StringUtils.isNotBlank( webChatSharesVo.getPeriodname() )) {
			basicDBObject.put( "wechatShares.periodname", webChatSharesVo.getPeriodname() );
		}
		if (StringUtils.isNotBlank( webChatSharesVo.getIntro() )) {
			basicDBObject.put( "wechatShares.intro", webChatSharesVo.getIntro() );
		}
		if (StringUtils.isNotBlank( webChatSharesVo.getPeriodicaltitle() )) {
			basicDBObject.put( "wechatShares.periodicaltitle", webChatSharesVo.getPeriodicaltitle() );
		}
		// 排序条件
		// Document sortDocument = new Document();
		// sortDocument.put( "resources.publishDate", -1 );
		// 不显示的字段
		Document fetchFields = new Document();
		fetchFields.put( "_id", 0 );
		fetchFields.put( "wechatShares", 1 );
		fetchFields.put( "resources", 1 );
		/* fetchFields.put( "dhSpecialResourceDatasList", 0 ); */
		List<Document> documentsList = manager.queryPages( MongoTableName.DH_WECHAT_SHARES_RESOURCE, basicDBObject, new Document(), fetchFields,
				webChatSharesVo.getPageNumber(), webChatSharesVo.getPageSize() );
		try {
			if (null != documentsList && documentsList.size() > 0) {
				webChatSharesVosList = new ArrayList<WebChatSharesVo>();
				for (Document document : documentsList) {
					WebChatSharesVo webChatSharesVoObj = new WebChatSharesVo();

					WechatShares wechatShares = new WechatShares();
					wechatShares = (WechatShares) MongoDBUtils.setFieldValue( wechatShares,
							Document.parse( JsonUtils.toJson( document.get( "wechatShares" ) ) ) );
					if (null != wechatShares) {
						webChatSharesVoObj.setResId( wechatShares.getResId() );
						webChatSharesVoObj.setTitle( wechatShares.getTitle() );
						webChatSharesVoObj.setIntro( wechatShares.getIntro() );
						webChatSharesVoObj.setAuthor( wechatShares.getAuthor() );
						webChatSharesVoObj.setRefid( wechatShares.getRefid() );
						webChatSharesVoObj.setUserid( wechatShares.getUserid() );
						webChatSharesVoObj.setCreatetime( wechatShares.getCreatetime() );
						webChatSharesVoObj.setEdittime( wechatShares.getEdittime() );
						webChatSharesVoObj.setWxurl( wechatShares.getWxurl() );
						webChatSharesVoObj.setReflink( wechatShares.getReflink() );
						webChatSharesVoObj.setCoverurl( wechatShares.getCoverurl() );
						webChatSharesVoObj.setPeriodicaltitle( wechatShares.getPeriodicaltitle() );
						webChatSharesVoObj.setPeriodicalpath( wechatShares.getPeriodicalpath() );
						webChatSharesVoObj.setPeriodname( wechatShares.getPeriodname() );
						webChatSharesVoObj.setCoverid( wechatShares.getCoverid() );
						webChatSharesVoObj.setMaterialtag( wechatShares.getMaterialtag() );
						webChatSharesVoObj.setWxmediaid( wechatShares.getWxmediaid() );

						webChatSharesVoObj.setUprrescategoryid( wechatShares.getUprrescategoryid() );
						webChatSharesVoObj.setRescategoryid( wechatShares.getRescategoryid() );
						webChatSharesVoObj.setUprrescategoryname( wechatShares.getUprrescategoryname() );
						webChatSharesVoObj.setRescategoryname( wechatShares.getRescategoryname() );
						webChatSharesVoObj.setHtmltext( wechatShares.getHtmltext() );
						webChatSharesVoObj.setOperattime( wechatShares.getOperattime() );
					}
					Resources resources = new Resources();
					resources = (Resources) MongoDBUtils.setFieldValue( resources, Document.parse( JsonUtils.toJson( document.get( "resources" ) ) ) );
					if (null != resources) {
						webChatSharesVoObj.setStatus( resources.getStatus() );
					}
					if (!webChatSharesVosList.contains( webChatSharesVoObj )) {
						webChatSharesVosList.add( webChatSharesVoObj );
					}

				}
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}

		LogCvt.debug( "查询 webChatSharesVo 结果:" + JSON.toJSONString( webChatSharesVosList, true ) );
		return webChatSharesVosList;
	}

	/**
	 * 返回图文总数量.
	 * 
	 * @param map
	 * @return
	 */
	public static Integer findWebChatShareslesMaxCount(WebChatSharesVo webChatSharesVo, String institutionId) {
		MongoManager manager = new MongoManager();
		LogCvt.debug( MongoTableName.DH_WECHAT_SHARES_RESOURCE + "查图文列表总数量 ------->" );
		BasicDBObject basicDBObject = new BasicDBObject();
		basicDBObject.put( "institutionId", institutionId );

		if (StringUtils.isNotBlank( webChatSharesVo.getQueryCriteria() )) {
			Pattern pattern = Pattern.compile( ".*" + webChatSharesVo.getQueryCriteria() + ".*", Pattern.CASE_INSENSITIVE );
			basicDBObject.put( "wechatShares.title", pattern );
		}
		if (null != webChatSharesVo.getStatus()) {
			basicDBObject.put( "resources.status", webChatSharesVo.getStatus() );
		}
		// 时间查询
		if (webChatSharesVo.getStartPublishDate() != null && !webChatSharesVo.getStartPublishDate().equals( "" )) {
			basicDBObject.put( "wechatShares.operattime", new BasicDBObject().put( "$gte", webChatSharesVo.getStartPublishDate() ) );
			BasicDBObject gt = new BasicDBObject( "$gte", webChatSharesVo.getStartPublishDate() );
			basicDBObject.put( "wechatShares.operattime", gt );
		}
		if (webChatSharesVo.getEndPublishDate() != null && !webChatSharesVo.getEndPublishDate().equals( "" )) {
			BasicDBObject lt = new BasicDBObject( "$lte", webChatSharesVo.getEndPublishDate() );
			basicDBObject.put( "wechatShares.operattime", lt );
		}
		if (StringUtils.isNotBlank( webChatSharesVo.getAuthor() )) {
			Pattern pattern = Pattern.compile( ".*" + webChatSharesVo.getAuthor() + ".*", Pattern.CASE_INSENSITIVE );
			basicDBObject.put( "wechatShares.author", pattern );
		}
		if (StringUtils.isNotBlank( webChatSharesVo.getTerminalCode() )) {
			basicDBObject.put( "dhSpecialResourceDatasList.terminalCode", webChatSharesVo.getTerminalCode() );
		}
		if (StringUtils.isNotBlank( webChatSharesVo.getPeriodname() )) {
			basicDBObject.put( "wechatShares.periodname", webChatSharesVo.getPeriodname() );
		}
		if (StringUtils.isNotBlank( webChatSharesVo.getIntro() )) {
			basicDBObject.put( "wechatShares.intro", webChatSharesVo.getIntro() );
		}
		if (StringUtils.isNotBlank( webChatSharesVo.getPeriodicaltitle() )) {
			basicDBObject.put( "wechatShares.periodicaltitle", webChatSharesVo.getPeriodicaltitle() );
		}
		// 不显示的字段
		Document fetchFields = new Document();
		fetchFields.put( "_id", 0 );
		fetchFields.put( "resId", 1 );
		Integer maxCount = manager.queryAggregateListMaxCount( basicDBObject, MongoTableName.DH_WECHAT_SHARES_RESOURCE );

		LogCvt.debug( "查询 findWebChatShareslesMaxCount 总数量:" + maxCount );
		return maxCount;
	}

	public static WeChatSharesMongoVo findWeChatSharesResourceMongoVoByRedId(String redId, String institutionId) {

		MongoManager manager = new MongoManager();
		LogCvt.debug( MongoTableName.DH_WECHAT_SHARES_RESOURCE + "查微信分享列表 ------->" );
		BasicDBObject basicDBObject = new BasicDBObject();
		basicDBObject.put( "resTable", "mobile" );
		basicDBObject.put( "institutionId", "institutionId" );

		if (StringUtils.isNotBlank( redId )) {
			basicDBObject.put( "resId", redId );
		}

		// 排序条件
		Document sortDocument = new Document();
		sortDocument.put( "resources.publishDate", -1 );
		// 不显示的字段
		Document fetchFields = new Document();
		fetchFields.put( "_id", 0 );
		List<Document> documentsList = manager.queryPages( MongoTableName.DH_WECHAT_SHARES_RESOURCE, basicDBObject, sortDocument, fetchFields, 1 );
		WeChatSharesMongoVo weChatSharesMongoVo = null;
		try {
			if (null != documentsList && documentsList.size() > 0) {

				for (Document document : documentsList) {

					weChatSharesMongoVo = new WeChatSharesMongoVo();

					String resId = JSON.toJSONString( document.get( "resId" ) );
					weChatSharesMongoVo.setResId( resId );

					String resTable = JSON.toJSONString( document.get( "resTable" ) );
					weChatSharesMongoVo.setResTable( resTable );

					String resTypeId = JSON.toJSONString( document.get( "resTypeId" ) );
					weChatSharesMongoVo.setResTypeId( resTypeId );

					WechatShares wechatShares = new WechatShares();
					wechatShares = (WechatShares) MongoDBUtils.setFieldValue( wechatShares,
							Document.parse( JsonUtils.toJson( document.get( "wechatShares" ) ) ) );
					if (null != wechatShares) {
						weChatSharesMongoVo.setWechatShares( wechatShares );

					}

					Resources resources = new Resources();
					resources = (Resources) MongoDBUtils.setFieldValue( resources, Document.parse( JsonUtils.toJson( document.get( "resources" ) ) ) );
					if (null != resources) {
						weChatSharesMongoVo.setResources( resources );
					}

					DhResourceauditlogs resourceauditlogs = new DhResourceauditlogs();
					resourceauditlogs = (DhResourceauditlogs) MongoDBUtils.setFieldValue( resourceauditlogs,
							Document.parse( JsonUtils.toJson( document.get( "resourceauditlogs" ) ) ) );
					if (null != resourceauditlogs) {
						weChatSharesMongoVo.setResourceauditlogs( resourceauditlogs );
					}

					AuditLogs auditLogs = new AuditLogs();
					auditLogs = (AuditLogs) MongoDBUtils.setFieldValue( auditLogs, Document.parse( JsonUtils.toJson( document.get( "auditLogs" ) ) ) );
					if (null != auditLogs) {
						weChatSharesMongoVo.setAuditLogs( auditLogs );
					}

					DhTodayStorageInfos todayStorageInfos = new DhTodayStorageInfos();
					todayStorageInfos = (DhTodayStorageInfos) MongoDBUtils.setFieldValue( todayStorageInfos,
							Document.parse( JsonUtils.toJson( document.get( "todayStorageInfos" ) ) ) );
					if (null != todayStorageInfos) {
						weChatSharesMongoVo.setTodayStorageInfos( todayStorageInfos );
					}

					List<SpecialResourceDatas> dhSpecialResourceDatasList = new ArrayList<SpecialResourceDatas>();
					dhSpecialResourceDatasList = JSONArray.parseArray( JsonUtils.toJson( document.get( "dhSpecialResourceDatasList" ) ),
							SpecialResourceDatas.class );
					if (null != dhSpecialResourceDatasList && dhSpecialResourceDatasList.size() > 0) {
						weChatSharesMongoVo.setDhSpecialResourceDatasList( dhSpecialResourceDatasList );
					}

					List<ResourceRelations> dhResourceRelationsList = new ArrayList<ResourceRelations>();
					dhResourceRelationsList = JSONArray.parseArray( JsonUtils.toJson( document.get( "dhResourceRelationsList" ) ),
							ResourceRelations.class );
					if (null != dhResourceRelationsList && dhResourceRelationsList.size() > 0) {
						weChatSharesMongoVo.setDhResourceRelationsList( dhResourceRelationsList );
					}

					List<ResCategoryRelations> resCategoryRelationsList = new ArrayList<ResCategoryRelations>();
					resCategoryRelationsList = JSONArray.parseArray( JsonUtils.toJson( document.get( "resCategoryRelationsList" ) ),
							ResCategoryRelations.class );
					if (null != resCategoryRelationsList && resCategoryRelationsList.size() > 0) {
						weChatSharesMongoVo.setResCategoryRelationsList( resCategoryRelationsList );
					}
				}
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}

		LogCvt.debug( "查询 weChatSharesMongoVo 结果:" + JSON.toJSONString( weChatSharesMongoVo, true ) );
		return weChatSharesMongoVo;
	}

	/**
	 * 通过资源idlist 和机构id获取图文列表.
	 * 
	 * @param redIdList
	 * @param institutionId
	 * @return
	 */
	public static List<WeChatSharesMongoVo> getWeChatSharesResourceListMongoVoByRedId(List<String> redIdList, String institutionId) {
		MongoManager manager = new MongoManager();
		LogCvt.debug( MongoTableName.DH_WECHAT_SHARES_RESOURCE + "查微信分享列表 ------->" );
		BasicDBObject basicDBObject = new BasicDBObject();
		basicDBObject.put( "resTable", "mobile" );
		basicDBObject.put( "institutionId", "institutionId" );

		if (null != redIdList && redIdList.size() > 0) {
			basicDBObject.put( "resId", new BasicDBObject( "$in", redIdList ) );
		}

		// 排序条件
		Document sortDocument = new Document();
		sortDocument.put( "resources.publishDate", -1 );
		// 不显示的字段
		Document fetchFields = new Document();
		fetchFields.put( "_id", 0 );
		List<Document> documentsList = manager.queryPages( MongoTableName.DH_WECHAT_SHARES_RESOURCE, basicDBObject, sortDocument, fetchFields, 1 );
		List<WeChatSharesMongoVo> weChatSharesMongoVoList = null;
		try {
			if (null != documentsList && documentsList.size() > 0) {
				weChatSharesMongoVoList = new ArrayList<WeChatSharesMongoVo>();
				for (Document document : documentsList) {
					WeChatSharesMongoVo weChatSharesMongoVo = new WeChatSharesMongoVo();

					String resId = JSON.toJSONString( document.get( "resId" ) );
					weChatSharesMongoVo.setResId( resId );

					String resTable = JSON.toJSONString( document.get( "resTable" ) );
					weChatSharesMongoVo.setResTable( resTable );

					String resTypeId = JSON.toJSONString( document.get( "resTypeId" ) );
					weChatSharesMongoVo.setResTypeId( resTypeId );

					WechatShares wechatShares = new WechatShares();
					wechatShares = (WechatShares) MongoDBUtils.setFieldValue( wechatShares,
							Document.parse( JsonUtils.toJson( document.get( "wechatShares" ) ) ) );
					if (null != wechatShares) {
						weChatSharesMongoVo.setWechatShares( wechatShares );

					}

					Resources resources = new Resources();
					resources = (Resources) MongoDBUtils.setFieldValue( resources, Document.parse( JsonUtils.toJson( document.get( "resources" ) ) ) );
					if (null != resources) {
						weChatSharesMongoVo.setResources( resources );
					}

					DhResourceauditlogs resourceauditlogs = new DhResourceauditlogs();
					resourceauditlogs = (DhResourceauditlogs) MongoDBUtils.setFieldValue( resourceauditlogs,
							Document.parse( JsonUtils.toJson( document.get( "resourceauditlogs" ) ) ) );
					if (null != resourceauditlogs) {
						weChatSharesMongoVo.setResourceauditlogs( resourceauditlogs );
					}

					AuditLogs auditLogs = new AuditLogs();
					auditLogs = (AuditLogs) MongoDBUtils.setFieldValue( auditLogs, Document.parse( JsonUtils.toJson( document.get( "auditLogs" ) ) ) );
					if (null != auditLogs) {
						weChatSharesMongoVo.setAuditLogs( auditLogs );
					}

					DhTodayStorageInfos todayStorageInfos = new DhTodayStorageInfos();
					todayStorageInfos = (DhTodayStorageInfos) MongoDBUtils.setFieldValue( todayStorageInfos,
							Document.parse( JsonUtils.toJson( document.get( "todayStorageInfos" ) ) ) );
					if (null != todayStorageInfos) {
						weChatSharesMongoVo.setTodayStorageInfos( todayStorageInfos );
					}

					List<SpecialResourceDatas> dhSpecialResourceDatasList = new ArrayList<SpecialResourceDatas>();
					dhSpecialResourceDatasList = JSONArray.parseArray( JsonUtils.toJson( document.get( "dhSpecialResourceDatasList" ) ),
							SpecialResourceDatas.class );
					if (null != dhSpecialResourceDatasList && dhSpecialResourceDatasList.size() > 0) {
						weChatSharesMongoVo.setDhSpecialResourceDatasList( dhSpecialResourceDatasList );
					}

					List<ResourceRelations> dhResourceRelationsList = new ArrayList<ResourceRelations>();
					dhResourceRelationsList = JSONArray.parseArray( JsonUtils.toJson( document.get( "dhResourceRelationsList" ) ),
							ResourceRelations.class );
					if (null != dhResourceRelationsList && dhResourceRelationsList.size() > 0) {
						weChatSharesMongoVo.setDhResourceRelationsList( dhResourceRelationsList );
					}

					List<ResCategoryRelations> resCategoryRelationsList = new ArrayList<ResCategoryRelations>();
					resCategoryRelationsList = JSONArray.parseArray( JsonUtils.toJson( document.get( "resCategoryRelationsList" ) ),
							ResCategoryRelations.class );
					if (null != resCategoryRelationsList && resCategoryRelationsList.size() > 0) {
						weChatSharesMongoVo.setResCategoryRelationsList( resCategoryRelationsList );
					}

					if (!weChatSharesMongoVoList.contains( weChatSharesMongoVo )) {
						weChatSharesMongoVoList.add( weChatSharesMongoVo );
					}
				}
			}
		} catch (Exception ex) {
			ex.printStackTrace();
			LogCvt.error( "查询 weChatSharesMongoVo 结果:" + ex.getMessage() );
		}

		LogCvt.debug( "查询 weChatSharesMongoVo 结果:" + JSON.toJSONString( weChatSharesMongoVoList, true ) );
		return weChatSharesMongoVoList;
	}

}